package com.base.home.adapter;

import android.databinding.DataBindingUtil;
import android.view.View;
import com.base.commonlib.recy.BasicRecyViewHolder;
import com.base.commonlib.recy.HFSingleTypeRecyAdapter;
import com.base.home.R;
import com.base.home.databinding.ItemCoursewareBinding;
import com.base.home.databinding.ItemNewimgBinding;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;

/**
 * 在此写用途
 *
 * @version V1.0 <描述当前版本功能>
 *          Created by admin on 2018/5/22.
 * @FileName: com.zhongyue.mdchengguan.ui.main.adapter.CategoryAdapter.java
 * Author weikailiang
 * @date: 2018-05-22 17:31
 */
public class NewImgAdapter extends HFSingleTypeRecyAdapter<String,NewImgAdapter.RecyViewHolder> {


    public NewImgAdapter(int resId) {
        super(resId);
    }

    @Override
    public RecyViewHolder buildViewHolder(View itemView) {
        return new RecyViewHolder(itemView);
    }

    @Override
    public void bindDataToHolder(RecyViewHolder holder,String str, int position) {
        RequestOptions options = new RequestOptions()
                .placeholder(R.drawable.ic_empty)
                .error(R.drawable.ic_empty)
                .diskCacheStrategy(DiskCacheStrategy.RESOURCE);
        Glide.with(holder.mBinding.img.getContext())
                .load(str)
                .apply(options)
                .into(holder.mBinding.img);
        holder.mBinding.img.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

            }
        });
    }

    public static class RecyViewHolder extends BasicRecyViewHolder {
        private ItemNewimgBinding mBinding;
        public RecyViewHolder(View itemView) {
            super(itemView);
            mBinding = DataBindingUtil.bind(itemView);
        }
    }
}
